<extend name="Public/base" />

<block name="body">
    <div class="main-title" style="padding-bottom: 10px;">
        <h2>{$title}</h2>
    </div>
    <div class="row ng-cloak" ng-controller="LossCtrl" ng-cloak >
        <form action="{:U('lossadd')}" method='post' class="form-horizontal" ng-init='lossinit()'>
            <div class="col-md-12">
                <div class="form-item">
                    <table class="table ">
                        <tr>
                            <th>单号</th>
                            <td>{$lossNumber}
                                <input type="text" name="lossNumber" class="hide" value="{$lossNumber}">
                            </td>
                            <th>申请人</th>
                            <td><input type="text" name="applicant" class="form-control input-3x"></td>
                            <th>申请时间</th>
                            <td><input type="text" name="applyTime" class="time form-control input-3x"></td>
                        </tr>
                        <tr>
                            <th>审核财务</th>
                            <td><input type="text" name="treasurer" class="form-control input-3x"></td>
                            <th>经办人</th>
                            <td><input type="text" name="operator" class="form-control input-3x"></td>
                            <th>库管</th>
                            <td><input type="text" name="storeManager" class="form-control input-3x"></td>
                        </tr>
                    </table>
                </div>
                <div class="panel panel-primary" style="width: 60%">
                    <div class="panel-heading">操作提示</div>
                    <div class="panel-body row" style="font-size: 18px;">
                        <ol class="col-lg-5">
                            <li>1.报损编码以实际报损BIN为准</li>
                            <li>2.报损批次为预警批次YP</li>
                            <li>3.YP编码需解密</li>
                        </ol>
                        <div>
                            <img style="width:40%" src="__IMG__/baosunlizi.png">
                        </div>
                    </div>
                </div>
                <div class="panel panel-default">
                    <div class="panel-heading" style="padding-bottom: 5px;padding-top: 5px;">
                        <span class="check-tips"><button type="button" class='btn btn-primary' ng-click="moreItems()">添加新商品</button></span></div>
                    <div class="panel-body" style="padding-bottom: 0px;padding-top: 0px;">
                        <div class="form-item cf">
                            <div class="controls">
                                <div style="border: #000 1px solid;margin-top: 5px;margin-bottom: 5px;" class='data-table table-striped '>
                                    <table  id="tbodyspec">
                                        <thead>
                                        <tr>
                                            <th scope="col" width="20%">商品编码[BIN]</th>
                                            <th scope="col" width="20%">批次[YP]</th>
                                            <th scope="col">数量</th>
                                            <th scope="col">方式</th>
                                            <th scope="col">原因</th>
                                            <th scope="col">时间</th>
                                            <th scope="col">操作</th>
                                        </tr>
                                        </thead>
                                        <tbody id="tbodyspec_a">
                                            <tr ng-repeat="item in items">
                                                <td class="change">
                                                    <select select2  class="form-control input-sm" ng-change="lossProductSelect($index,x)" ng-model="x">
                                                        <option value="">请选择...</option>
                                                        <option ng-repeat="p in productList" value="{{($index)}}" >{{p.BIN}}({{p.pname}}{{p.spec}})</option>
                                                        <!--<volist name="_prolist" id="pl"><option data-num="{$pl.cnt}" value="{$pl.id}">{$pl.pname}({$pl.spec})</option></volist>-->
                                                        <input type="text" name="BIN[]" class="hide" ng-model="item.BIN">
                                                    </select>
                                                </td>
                                                <td>
                                                    <select select2 name="warn_batch[]" class="form-control input-3x"  >
                                                        <option></option>
                                                        <option ng-repeat="i in item.batchList" value="{{i.warn_batch}}" >{{i.warn_batch}}[{{i.cnt}}]</option>
                                                    </select>
                                                </td>
                                                <td>
                                                   <input class="cnt form-control input-2x form-inline" style="display: inline" type="text" name="cnt[]" required /> <span ng-bind="item.unit"></span>
                                                    <input type="text" name="unit[]" class="form-control input-x hide" ng-model="item.unit" >
                                                </td>
                                                <td>
                                                    <select name="loss_type[]"  >
                                                        <option>直报</option>
                                                        <option>转榨汁</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <select name="reason[]" class="">
                                                        <option ng-repeat="lossReason in lossReasonList">{{lossReason}}</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <input type="text" name="lossAt[]" class="time form-control input-3x" />
                                                </td>
                                                <td>
                                                    <button type="button" class="btn btn-info" ng-click="removeItem($index)"> - </button>
                                                </td>
                                            </tr>
                                        <!--读取商品信息-->
                                            <tr id="tflag"></tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-12">
                <button type="submit" class="btn confirm btn-danger ajax-post" target-form="form-horizontal">保 存</button>
                <a  class="btn btn-primary" id="fh" onclick="javascript:history.back(-1); return false;">返 回</a>
            </div>
        </form>
    </div>
</block>

<block name="script">
    <script type="text/javascript" src="__JS__/loss.js"></script>
    <script type="text/javascript">
        highlight_subnav('{:U('Inventory/lossadd')}');
        $(".time").datetimepicker(
                {
                    format: 'Y-m-d H:i:s',
                    todayButton: true,
                    step:20,
                }
        )

    </script>
</block>
